package com.woniuxy.microretailserver.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.microretailserver.bean.GoodsOrderBean;
import com.woniuxy.microretailserver.bean.OrderGoodsBean;
import com.woniuxy.microretailserver.bean.PageRequest;
import com.woniuxy.microretailserver.service.IGoodsOrderService;
import com.woniuxy.microretailserver.service.IOrderGoodsService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author chenhu
 * 商品交易明细控制层
 */
@RestController
@RequestMapping("/tran")
public class TranDetailsController {

    @Resource
    private IOrderGoodsService orderGoodsServiceImpl;

    /**
     *展示商品交易明细数据
     * @param request
     * @return
     */
    @RequestMapping(value = "/goodsorder",produces = MediaType.APPLICATION_JSON_VALUE)
    public PageInfo<OrderGoodsBean> findAllGoodsOrder(PageRequest request){
        OrderGoodsBean orderGoodsBean = new OrderGoodsBean();
        PageInfo<OrderGoodsBean> pageOrder = orderGoodsServiceImpl.findPageOrder(request, orderGoodsBean);
        return pageOrder;
    }

    /**
     * 模糊查询商品交易明细数据
     * 根据商品名字或编号
     * @param request
     * @param orderGoodsBean
     * @return
     */
    @GetMapping(value = "/goodsn",produces = MediaType.APPLICATION_JSON_VALUE)
    public PageInfo<OrderGoodsBean> findByGoodsNum(PageRequest request,OrderGoodsBean orderGoodsBean){
        PageInfo<OrderGoodsBean> pageOrder = orderGoodsServiceImpl.findPageOrder(request, orderGoodsBean);
        return pageOrder;
    }
}
